<script setup lang="ts">
defineProps<{
  items?: string[]
}>()

const emit = defineEmits<{
  (e: 'chooseItem', index: number): void
}>()

const onClickItem = (index: number) => {
  emit('chooseItem', index)
}
</script>

<template>
  <div class="menu-list">
    <ul class="list">
      <li v-for="(item, index) in items" :key="index"
          class="item"
          @click="onClickItem(index)">
        {{ item }}
      </li>
    </ul>
  </div>
</template>

<style scoped>
.menu-list {
  display: none;
  position: absolute;
  width: 160px;
  min-height: 40px;
  top: 40px;
  left: -2px;
  border-radius: 8px;
  border: 1px solid color-mix(in oklab, var(--border) 85%, transparent);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(12, 18, 32, 0.55);
  backdrop-filter: blur(10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  opacity: 0;
  z-index: 100;
}

.menu-list:hover {
  display: flex;
  opacity: 1;
}

.list {
  width: 100%;
  height: 100%;
  list-style: none;
  margin: 0;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

.item {
  width: 100%;
  padding: 8px 12px;
  cursor: pointer;
  border-radius: 8px;
  outline: none;
}

.item:hover,
.item:focus {
  background: rgba(255, 255, 255, 0.05);
}
</style>
